/**
 * @Auther: wangliuyang
 * @Date: 2021/4/22 20:55
 * @Description:
 */
public class Solution_80 {
        public int removeDuplicates(int[] nums) {
            if(nums.length == 0) {
                return 0;
            }
            int i = 0;
            boolean flag = true;
            for(int j =1 ; j < nums.length ; j++){
                if(nums[i] != nums[j]){
                    nums[++i] = nums[j];
                    flag = true;
                }else{
                    if(flag){
                        nums[++i] = nums[j];
                        flag = false;
                    }
                }
            }
            return i+1;
        }
}
